﻿
using System.Collections.Generic;
using System.Data;
using System;
namespace ZHDJ.MobileInterface
{
    public partial class GetCircleAdvertDetail : AbstractBasePage
    {
        protected override OutParam BusinessProcess<InParam, OutParam>(InParam inParam)
        {
            // 业务逻辑返回的响应对象  
            CircleAdvertDetailOutParam result = new CircleAdvertDetailOutParam();
            CircleAdvertDetailInParam param = new CircleAdvertDetailInParam();
            string logMsg = "";
            bool isFlag = true;
                 
            try
            {
                param = inParam as CircleAdvertDetailInParam;
                if (string.IsNullOrEmpty(param.ad_id))
                {
                    result.code = "0";
                    result.desc = "广告ID不能为空";

                    isFlag = false;
                } 

                if (isFlag)
                { 
                    DataSet dsDetail = InterfaceHelper.GetCircleAdvertDetail(param.ad_id);
                    if (dsDetail != null && dsDetail.Tables[0].Rows.Count > 0)
                    {
                        result.data.address = dsDetail.Tables[0].Rows[0]["address"].ToString();
                        result.data.content = dsDetail.Tables[0].Rows[0]["content"].ToString();
                        result.data.name = dsDetail.Tables[0].Rows[0]["name"].ToString();
                        result.data.photo_main = dsDetail.Tables[0].Rows[0]["photo_main"].ToString();
                        result.data.photo_main = CommonUtils.AppAddress + SXT.Utility.FileServer.QueryFileUrl(result.data.photo_main);
                        result.data.time_end = dsDetail.Tables[0].Rows[0]["time_end"].ToString();
                        result.data.time_start = dsDetail.Tables[0].Rows[0]["time_start"].ToString(); 
                    }  
                }

                logMsg = result.desc;
            }
            catch (Exception ex)
            {
                result.code = "0";
                result.desc = "操作异常，多次出现请联系管理员"; 
                logMsg = ex.Message + ":" + ex.StackTrace;
            }

            CommonUtils.InsertMobileInterfaceLog(SystemCode +"-GetCircleAdvertDetail", SerializeHelper.JsonSerializer<CircleAdvertDetailInParam>(param), logMsg); 
            return result as OutParam;
        }

        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (string.Compare(Request.QueryString["Safe"], "False", true) == 0)
                ProcessRequest<CircleAdvertDetailInParam, CircleAdvertDetailOutParam>();
            else
                SafeProcessRequest<CircleAdvertDetailInParam, CircleAdvertDetailOutParam>();
        }
    }

    #region 请求参数
    public class CircleAdvertDetailInParam
    {
        /// <summary>
        /// 必填 广告ID
        /// </summary>
        public string ad_id
        { get; set; } 
    }
    #endregion

    #region 结果参数
    public class CircleAdvertDetailOutParam
    {
        public CircleAdvertDetailOutParam()
        {
            code = "1";
            desc = "操作成功";
            data = new CircleAdvertDetail();
        }

        /// <summary>
        /// 返回结果 具体见接口返回对照码 1	成功 0	失败 2	请求非法 加密结果和传入的MD5字符串进行比较，如果相同则执行接口操作，否则返回1001错误响应码
        /// </summary>
        public string code
        { get; set; }

        /// <summary>
        /// 结果描述 成功和失败都需要
        /// </summary>
        public string desc
        { get; set; }

        /// <summary>
        /// 广告的详细内容
        /// </summary>
        public CircleAdvertDetail data
        { get; set; }
    } 

    /// <summary>
    /// 广告的详细内容
    /// </summary>
    public class CircleAdvertDetail
    {
        /// <summary>
        ///	广告名称		 
        /// </summary>
        public string name
        { get; set; }
        /// <summary>
        ///	开始时间		 
        /// </summary>
        public string time_start
        { get; set; }
        /// <summary>
        ///	结束时间		 
        /// </summary>
        public string time_end
        { get; set; }
        /// <summary>
        ///	活动地点		 
        /// </summary>
        public string address
        { get; set; }
        /// <summary>
        ///	活动内容		 
        /// </summary>
        public string content
        { get; set; }
        /// <summary>
        ///	活动主图片		 
        /// </summary>
        public string photo_main
        { get; set; } 
    }
    #endregion 
}